home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 May / maximum-cd-1999-05.iso / Canvas 6 / DATA1.CAB / English_Tutorial_Files / Viewpage / ColSnd.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-04  |  2.8 KB  |  126 lines

  1. import java.applet.AudioClip;
  2. import java.awt.Color;
  3. import java.awt.Event;
  4. import java.awt.Graphics;
  5. import java.awt.Polygon;
  6. import java.awt.Rectangle;
  7. import java.io.DataInputStream;
  8. import java.io.IOException;
  9. import java.net.URL;
  10.  
  11. final class ColSnd extends ColObj {
  12.    private AudioClip m_colSnd;
  13.    private ColGrph m_colGraphicObj;
  14.    public Rectangle m_bounds;
  15.    private byte playType = 1;
  16.    private String thePath;
  17.    private byte visable = 1;
  18.    public boolean muted;
  19.  
  20.    public boolean EventProc(Event var1) {
  21.       boolean var4 = false;
  22.       if (var1 != null) {
  23.          int var2 = (int)(((float)var1.x + this.m_colGraphicObj.m_xOrg * this.m_colGraphicObj.m_mag) / this.m_colGraphicObj.m_mag);
  24.          int var3 = (int)(((float)var1.y + this.m_colGraphicObj.m_yOrg * this.m_colGraphicObj.m_mag) / this.m_colGraphicObj.m_mag);
  25.          if (var1.key == 6969) {
  26.             this.muted = true;
  27.             var4 = true;
  28.          }
  29.  
  30.          if (var1.key == 6970) {
  31.             this.muted = false;
  32.             var4 = true;
  33.          }
  34.  
  35.          if (var1.key == 6971) {
  36.             this.PlayClip();
  37.             var4 = true;
  38.          }
  39.  
  40.          if (var1.id == 502 && this.m_bounds.inside(var2, var3)) {
  41.             if (this.playType == 2) {
  42.                this.PlayClip();
  43.             }
  44.  
  45.             var4 = true;
  46.          }
  47.       } else {
  48.          this.PlayClip();
  49.          var4 = true;
  50.       }
  51.  
  52.       return var4;
  53.    }
  54.  
  55.    public void draw(Graphics var1) {
  56.       if (this.m_colSnd != null && this.visable == 1) {
  57.          int var2 = (int)(((float)this.m_bounds.x - this.m_colGraphicObj.m_xOrg) * this.m_colGraphicObj.m_mag);
  58.          int var3 = (int)(((float)this.m_bounds.y - this.m_colGraphicObj.m_yOrg) * this.m_colGraphicObj.m_mag);
  59.          int var4 = (int)((float)this.m_bounds.width * this.m_colGraphicObj.m_mag);
  60.          int var5 = (int)((float)this.m_bounds.height * this.m_colGraphicObj.m_mag);
  61.          var1.setColor(Color.blue);
  62.          var1.fillRect(var2, var3 + var5 / 2, var4 / 4, var5 / 2);
  63.          var1.setColor(Color.red);
  64.          Polygon var6 = new Polygon();
  65.          var6.addPoint(var2, var3 + var5 / 2);
  66.          var6.addPoint(var2 + var4 / 2, var3);
  67.          var6.addPoint(var2 + var4 / 2, var3 + var5);
  68.          var6.addPoint(var2, var3 + var5 / 2);
  69.          var1.drawPolygon(var6);
  70.          var1.fillPolygon(var6);
  71.          var1.setColor(Color.yellow);
  72.          var1.drawOval(var2 + var4 / 2, var3, var4 / 4, var5);
  73.          var1.setColor(Color.yellow.darker());
  74.          var1.fillOval(var2 + var4 / 2, var3, var4 / 4, var5);
  75.       }
  76.  
  77.    }
  78.  
  79.    public ColSnd(DataInputStream var1, ColGrph var2, Graphics var3) throws IOException {
  80.       this.m_colGraphicObj = var2;
  81.       this.m_bounds = new Rectangle();
  82.       this.m_bounds.y = (int)((float)var1.readInt() / 65536.0F);
  83.       this.m_bounds.x = (int)((float)var1.readInt() / 65536.0F);
  84.       this.m_bounds.height = (int)((float)var1.readInt() / 65536.0F);
  85.       this.m_bounds.width = (int)((float)var1.readInt() / 65536.0F);
  86.       this.playType = var1.readByte();
  87.       int var5 = var1.readInt();
  88.       super.cvObjNum = (long)var1.readInt();
  89.       this.visable = var1.readByte();
  90.       this.thePath = new String();
  91.  
  92.       for(int var4 = 0; var4 < var5; ++var4) {
  93.          String var10001 = this.thePath;
  94.          this.thePath = var10001 + (char)var1.readByte();
  95.       }
  96.  
  97.       var1.readByte();
  98.       this.m_colSnd = this.m_colGraphicObj.m_appComp.getAudioClip(new URL(this.m_colGraphicObj.m_appComp.m_cvFilePath), this.thePath);
  99.       this.m_colGraphicObj.m_appComp.showStatus("Reading sound object please wait...");
  100.       if (this.m_colSnd != null) {
  101.          if (this.playType == 1) {
  102.          }
  103.  
  104.          if (this.playType == 3) {
  105.             this.m_colSnd.play();
  106.          }
  107.       }
  108.  
  109.    }
  110.  
  111.    public void PlayClip() {
  112.       if (this.m_colSnd != null && !this.muted) {
  113.          this.m_colSnd.play();
  114.       }
  115.  
  116.    }
  117.  
  118.    public int getType() {
  119.       return 16;
  120.    }
  121.  
  122.    public Rectangle getBounds() {
  123.       return this.m_bounds;
  124.    }
  125. }
  126.